import menu from './menu';
import request from './request';
import jump from './jump';
import carryFN from './carryFN';
import delay from './delay';
import diffTimer from './diffTimer';

// 日期格式化
/*eslint no-extend-native:0*/
Date.prototype.format = function format(input) {
    let res = input;
    const o = {
        'M+': this.getMonth() + 1,
        'd+': this.getDate(),
        'h+': this.getHours(),
        'H+': this.getHours(),
        'm+': this.getMinutes(),
        's+': this.getSeconds(),
        'q+': Math.floor((this.getMonth() + 3) / 3),
        S: this.getMilliseconds()
    };
    if (/(y+)/.test(res)) {
        res = res.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
    }
    for (let k in o) {
        if (new RegExp('(' + k + ')').test(res)) {
            res = res.replace(RegExp.$1, RegExp.$1.length === 1
                ? o[k]
                : ('00' + o[k]).substr(('' + o[k]).length));
        }
    }
    return res;
};

module.exports = {
    menu,
    jump,
    delay,
    carryFN,
    request,
    diffTimer,
};
